# Created with PyCharm.
# Project_Name SoftwareTesting2022
# PATH Needing
# Files_Name 页面截图.py
# Coding UTF-8
# @Version Python 3.8

# @author GeekChunky
# @Email caiyoupeng00@outlook.com

# @Date 2021/11/24
# @CreatTime 19:40


'''
Documentation comments:
    新增资产类别，保存成功后进行截图
'''

# Now Write Down Your Python Code in Editor...
# Wish You Happy Everyday !
from time import sleep

from selenium import webdriver
# 2、使用Selenium模块的WebDriver打开谷歌浏览器；
from selenium.webdriver.common.by import By

driver = webdriver.Edge(r'C:\Users\caiyo\AppData\Local\Programs\Python\Python38\BroswerDriver\msedgedriver.exe')
driver.maximize_window()
driver.get("http://192.168.1.251/bsams/front/login.do")
driver.find_element(By.XPATH, '//*[@id="taskId"]').send_keys('682')
driver.find_element(By.XPATH, '//*[@id="loginName"]').send_keys('xg01')
driver.find_element(By.XPATH, '//*[@id="password"]').send_keys('xg01')
driver.find_element(By.XPATH, '//*[@id="vericode"]').send_keys('shtd')
driver.find_element(By.CLASS_NAME, 'dl-button').click()
driver.find_element(By.LINK_TEXT, '资产类别').click()
sleep(1)
# 截图方式1
# driver.save_screenshot('screenshot.png')
# 截图方式2
driver.get_screenshot_as_file('screenshot.png')
# 出现警示弹框时无法使用脚本截图
sleep(1)
driver.find_element_by_xpath('/html/body/div[1]/div/div[3]').click()
sleep(1)
driver.close()
